﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace THenu.TinyHourseLib.DesignPattern.Specification_Pattern
{
    public class ORSpecification<T> :CompositeSpecification<T>
    {
        /// <summary>
        /// 加运算左参数
        /// </summary>
        ISpecification<T> leftSpecification;
        /// <summary>
        /// 加运算右参数
        /// </summary>
        ISpecification<T> rightSpecification;
        /// <summary>
        /// 加运算
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        public ORSpecification(ISpecification<T> left, ISpecification<T> right)
        {
            this.leftSpecification = left;
            this.rightSpecification = right;
        }
        /// <summary>
        /// 重新实现自描述
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public override bool IsSatisfiedBy(T o)
        {
            return this.leftSpecification.IsSatisfiedBy(o)
                || this.rightSpecification.IsSatisfiedBy(o);
        }
    }
}
